package com.duoduo.demo.springnoxml.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.duoduo.demo.springnoxml.service.HelpService;
import com.duoduo.demo.springnoxml.vo.HelpCategoryVO;
import com.duoduo.demo.springnoxml.vo.HelpKeywordVO;
import com.duoduo.demo.springnoxml.vo.HelpTopicVO;

@Controller
public class HelpController {

	@Autowired
	private HelpService helpService;

	@RequestMapping(value = {
			"/help/category", "/help/category/list"
	})
	public String listCategory() {
		return "help/category-list";
	}

	@RequestMapping("/help/category/parent/{parentId}")
	@ResponseBody
	public List<HelpCategoryVO> listCategoryByParent(@PathVariable Integer parentId) {
		return helpService.listCategoryByParent(parentId);
	}

	@RequestMapping(value = {
			"/help/keyword", "/help/keyword/list"
	})
	public String listKeyword() {
		return "help/keyword-list";
	}

	@RequestMapping("/help/keyword/{keywordId}/topics")
	@ResponseBody
	public List<HelpTopicVO> listTopicByKeyword(@PathVariable Integer keywordId) {
		return helpService.listTopicByKeyword(keywordId);
	}

	@RequestMapping(value = {
			"/help/topic", "/help/topic/list"
	})
	public String listTopic() {
		return "help/topic-list";
	}

	@RequestMapping("/help/topic/category/{categoryId}")
	@ResponseBody
	public List<HelpTopicVO> listTopicByCategory(@PathVariable Integer categoryId) {
		return helpService.listTopicByCategory(categoryId);
	}

	@RequestMapping("/help/topic/{topicId}/keywords")
	@ResponseBody
	public List<HelpKeywordVO> listKeywordByTopic(@PathVariable Integer topicId) {
		return helpService.listKeywordByTopic(topicId);
	}
}
